﻿using System.Collections.Generic;
using Truextend.Training.Business;
using Truextend.Training.Business.Interfaces;
using Truextend.Training.Model.Entities;

namespace Truextend.Training.Service
{
    public class CourseService: BaseService
    {
        public IList<Course> GetAllCourses()
        {
            IList<Course> result = null;
            ExecuteManager(uow=>
                               {
                                   ICourseManager manager = new CourseManager(uow);
                                   result = manager.GetAllCourses();
                               });
            return result;
        }

        public void AddCourse(Course course)
        {
            ExecuteManager(uow =>
            {
                ICourseManager manager = new CourseManager(uow);
                manager.AddCourse(course);
            });
        }

        public void EditCourse(Course course)
        {
            ExecuteManager(uow =>
            {
                ICourseManager manager = new CourseManager(uow);
                manager.EditCourse(course);
            });
        }

        public void DeleteCourse(long courseId)
        {
            ExecuteManager(uow =>
            {
                ICourseManager manager = new CourseManager(uow);
                manager.DeleteCourse(courseId);
            });
        }

        public Course GetCourseById(long courseId)
        {
            Course course = null;
            ExecuteManager(uow =>
            {
                ICourseManager manager = new CourseManager(uow);
                course = manager.GetCourseById(courseId);                
            });
            return course;
        }
    }
}
